﻿using DiaoPaiDaYin;
using Luna小店.DTO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Luna小店.service.WinForm_Service
{
    /// <summary>
    /// PC端客户服务
    /// </summary>
    public class WinformCustomerService
    {
        public static DTO客户体态 get客户量体值(String CUSTOMER_ID)
        {
            //  客户量体值
            String sql = "SELECT\n" +
                    "	customer_fit.CUSTOMER_FIT_ID,\n" +
                    "	customer_fit.CUSTOMER_ID,\n" +
                    "	customer_fit.STYLE_CATEGORY_CD,\n" +
                    "	customer_fit.ITEM_CD,\n" +
                    "	customer_fit.ITEM_VALUE,\n" +
                    "	customer_fit.FIT_VALUE,\n" +
                    "	property.PROPERTY_NAME_CN,\n" +
                    "	property.PROPERTY_CD,\n" +
                    "	property.PROPERTY_VALUE,\n" +
                    "	property.PROPERTY_UNIT_CD,\n" +
                    "	customer_fit.STYLE_CATEGORY_CD,\n" +
                    "	dict.ITEM_NAME_CN AS `VALUE`\n" +
                    "	-- count.AGE,\n" +
                    "	-- count.SEX \n" +
                    "FROM\n" +
                    "	a_customer_fit_r customer_fit\n" +
                    "	LEFT JOIN a_fit_property_p property ON property.PROPERTY_VALUE = customer_fit.ITEM_VALUE\n" +
                    "	LEFT JOIN w_dict_option_p AS dict ON (dict.ITEM_CD = customer_fit.ITEM_VALUE AND dict.ITEM_VALUE=customer_fit.FIT_VALUE)\n" +
                    "	-- LEFT JOIN a_customer_fit_count_r count ON count.CUSTOMER_ID = customer_fit.CUSTOMER_ID \n" +
                    "	AND property.PROPERTY_VALUE = customer_fit.ITEM_VALUE \n" +
                    "WHERE\n" +
                    "	customer_fit.DELETE_FLAG = 0 \n" +
                    "	AND customer_fit.CUSTOMER_ID = '" + CUSTOMER_ID + "' \n" +
                    "	AND customer_fit.CREATE_DATE = ( SELECT CREATE_DATE FROM a_customer_fit_r WHERE CUSTOMER_ID = '" + CUSTOMER_ID + "' ORDER BY CREATE_DATE DESC LIMIT 1 ) \n" +
                    "ORDER BY\n" +
                    "	property.PROPERTY_COST;";
            String sql1 = "SELECT\n" +
                    "	* \n" +
                    "FROM\n" +
                    "	a_customer_fit_count_r \n" +
                    "WHERE\n" +
                    "	CUSTOMER_ID = '" + CUSTOMER_ID + "' ";
            return new DTO客户体态(SQLmtm.GetDataTable(sql), SQLmtm.GetDataRow(sql1));
        }
    }
}
